package com.test.springboot3.springboot3testdemo1.config;

import com.test.springboot3.springboot3testdemo1.servlet.InitServlet;
import jakarta.servlet.ServletRegistration;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/8/2-下午1:07
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Configuration
public class ServletConfig {
  @Bean
  public ServletContextInitializer servletContextInitializer() {
    return servletContext -> {
      ServletRegistration initServlet = servletContext.addServlet("initServlet", new InitServlet());
      initServlet.addMapping("/initServlet");
      initServlet.setInitParameter("name", "initServlet");
      initServlet.setInitParameter("sex", "male");
    };
  }
}
